package com.ty.day4;

import java.util.Scanner;

/**
 * Created by IntelliJ IDEA.
 *
 * @author : txy
 * @create : 2023/11/9 18:35
 */
public class Task4 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x, count = 0, score = 0, a, b;
        System.out.println("***欢迎来到计算乐园***");
        while (true) {
            a = (int) (Math.random() * 100);
            b = (int) (Math.random() * 100);
            count++;
            System.out.print("第" + count + "题.\t" + a + "+" + b + "= ");
            x = sc.nextInt();
            if (x == -1) {
                continue;
            }
            if (x == -2) {
                break;
            }
            if (x == a + b) {
                System.out.println("答对了");
                score += 10;
            }else {
                System.out.println("答错了");
            }
            if (count == 10) {
                break;
            }
        }
        System.out.println("游戏结束了，您的得分：" + score);
    }
}
